//
//  AppInitializer.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/7.
//

import Foundation
import UMCommon
import UMPush

class AppInitializer {
    static func initialize(delegate: AppDelegate) {
        showLog("执行应用初始化")
        initLeanCloud()
        initWeixin()
        initPush(delegate: delegate)
        SceneQQDelegate.shared.initSDK()
//        printCustomFonts()
    }
    
    
    static func initLeanCloud(){
        LeancloudManager.instance.initLeanCloud()
    }
    
    static func initWeixin(){
        WXApi.registerApp("wx6a3098d23d196e36", universalLink: "https://aiyuxm.com/imprint/")
    }
    
    static func initPush(delegate: AppDelegate){
        UMConfigure.initWithAppkey("67f3cdb4b8cd000d2c2b920b", channel: "App Store")
          // 请求推送权限
          let center = UNUserNotificationCenter.current()
          center.delegate = delegate
          center.requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in
              DispatchQueue.main.async {
                  if granted {
                      UIApplication.shared.registerForRemoteNotifications()
                  } else {
                      showLog("用户拒绝推送权限")
                  }
              }
          }
        UNUserNotificationCenter.current().getNotificationSettings { settings in
            showLog("推送权限状态: \(settings.authorizationStatus.rawValue)")
            showLog("APNs 环境: \(Bundle.main.appStoreReceiptURL?.lastPathComponent ?? "unknown")") // 输出 sandboxReceipt 或 receipt
        }
    }
}
